package com.youlu.campus.web.client;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(name = "qq",url = "https://graph.qq.com",fallbackFactory = QQFallbackFactory.class)
public interface QQTokenClient {

    /**
     * 获取AccessToken
     * @param grantType
     * @param clientId
     * @param clientSecret
     * @param code
     * @param redirectUri
     * @param fmt
     * @return
     */

//    @GetMapping(value = "/oauth2.0/token",produces ={"application/json;charset=utf-8"})
//    QQResult getAccessToken(@RequestParam(defaultValue = "authorization_code") String grant_type,
//                            String client_id,
//                            String client_secret,
//                            String code,
//                            @RequestParam ("redirect-uri")String redirectUri,
//                            String scope,
//                            @RequestParam (defaultValue = "json")String fmt);

    /**
     *  续期AccessToken
     * @param grantType
     * @param clientId
     * @param clientSecret
     * @param fmt
     * @return
     */
    @GetMapping(value = "/oauth2.0/token",produces = "application/json;charset=utf-8")
   QQResult getRenewalAccessToken(@RequestParam(defaultValue = "refresh_token",name = "grant_type",value = "grant_type") String grantType,
                                  @RequestParam(name = "client_id")String clientId,
                                  @RequestParam(name = "client_secret")String clientSecret,
                                  @RequestParam (defaultValue = "json")String fmt);

    /**
     * openId
     * @param accessToken
     * @param fmt
     * @return
     */
    @GetMapping(value ="/oauth2.0/me",produces = "application/json;charset=utf-8")
    QQResult getOpenId(@RequestParam(name = "access_token")String accessToken, @RequestParam (defaultValue = "json")String fmt);


    /**
     * 获取用户信息
     * @param accessToken
     * @param oauthConsumerKey
     * @param openId
     * @param fmt
     * @return
     */
    @GetMapping(value ="/user/get_user_info",produces = "application/json;charset=utf-8")
    QQUserInfoResult getUserInfo(@RequestParam(name = "access_token")String accessToken,
                         @RequestParam(name = "oauth_consumer_key")String oauthConsumerKey,
                         @RequestParam(name = "openid") String openId,
                  @RequestParam (defaultValue = "json")String fmt);






}
